<template>
  <c-main-template minHeight="auto" :isBreadcrumb="false">
    <el-row :gutter="24" class="pd-lg">
      <el-col :span="7">
        <div class="flex-y-center">
          <div class="mr-lg f-s-14">合同编号：</div>
          <el-input
            size="large"
            placeholder="请输入合同编号"
            v-model="querys.contractNb"
            class="wh flex-1 mr-lg"
          />
        </div>
      </el-col>
      <el-col :span="7">
        <div class="flex-y-center">
          <div class="mr-lg f-s-14">订单号：</div>
          <el-input
            size="large"
            placeholder="请输入订单号"
            v-model="querys.orderId"
            class="wh flex-1 mr-lg"
          />
        </div>
      </el-col>
      <el-col :span="7">
        <div class="flex-y-center">
          <div class="mr-lg f-s-14">日期：</div>
          <el-date-picker
            v-model="querys.time"
            value-format="YYYY-MM-DD HH:mm:ss"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            size="large"
            class="wh flex-1 mr-lg"
          />
        </div>
      </el-col>
      <el-col :span="3">
        <div class="flex-x-end">
          <el-button size="large" @click="handleReset">重 置</el-button>
          <el-button size="large" type="primary" @click="handleSelect"
            >查 询</el-button
          >
        </div>
      </el-col>
    </el-row>
  </c-main-template>
  <c-main-template
    v-loading="loading"
    class="mt-lg"
    minHeight="auto"
    title="交易订单合同"
    :isBreadcrumb="false"
  >
    <c-table-template :data="tableData">
      <el-table-column label="序号" align="center" type="index" width="60" />
      <el-table-column label="合同编号" prop="contractNb" align="center" />
      <el-table-column label="订单号" prop="innerId" align="center" />
      <el-table-column label="创建时间" align="left" width="200">
        <template #default="scope">
          {{ filters.dateYMDHMSFormat(scope.row.timeCreate) }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="200">
        <template #default="scope">
         <el-button
            link
            type="primary"
            size="small"
            @click="onFileOpen(scope.row.url)"
          >
            <span>查看合同</span>
          </el-button>
        </template>
      </el-table-column>
    </c-table-template>
    <div class="flex-x-end pd-20">
      <c-page-template
        :total="total"
        :querys="querys"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </c-main-template>
</template>
<script setup>
import { ref, getCurrentInstance } from "vue";
import { useBasicsTable } from "@/hooks/useTable.js";
const { proxy } = getCurrentInstance();
import {onFileOpen} from '@/utils/index.js'
const {
  querys,
  tableData,
  total,
  loading,
  tableList,
  handleSelect,
  handleSizeChange,
  handleCurrentChange,
  handleReset,
} = useBasicsTable({
  url: "/sellerContract/pageSeller",
  getParams: () => {
    // category 0-销售申请合同 1-订单合同
    // type 合同分类：0-模板，1-正式
    const params = {
      category: 1,
      type: 1,
    };
    if (querys.value.time && querys.value.time.length > 0) {
      params.startDate = querys.value.time[0];
      params.endDate = querys.value.time[1];
      params.time = null;
    }
    return params;
  },
});
</script>